package site.yunnong.atvris.portal.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.UserDetailsService;
import site.yunnong.atvris.portal.service.UserSsoService;
import site.yunnong.atvris.security.config.SecurityConfig;

import javax.annotation.Resource;

/**
 * @author JinghaoZhang
 * @date 2021年-04月-06日
 */
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class YunnongSecurityConfig extends SecurityConfig {

    @Resource
    private UserSsoService userSsoService;

    // 有了这一条，spring security就不会在console中debug 密码
    @Bean
    public UserDetailsService userDetailsService() {
        //获取登录用户信息
        return username -> userSsoService.loadUserDetailsByUsername(username);
    }
}
